package com.nlabs.slickgwt.client;

import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
 

 public class MenuButton extends ImageButton {
	 
	 private Menu m_menu = new Menu(); 
	 
	 public MenuButton(String text) {
		 
		 super();
		 this.setText(text);
		 this.setImageUrlAndRect("resources/toolicons.gif", 0, 3*14 , 14, 14);
		 this.setImageAlign(ImageAlign.RIGHT);
		 final MenuButton mb = this; 
		 this.addClickHandler(new ClickHandler(){

			public void onClick(ClickEvent event) {
				m_menu.showRelativeTo(mb) ;
				if(m_menu.getOffsetWidth() < getOffsetWidth()){
				 	m_menu.setWidth("" + getOffsetWidth());
				 }
			} 
		 }); 
	 }
	 
	 public void addMenuItem(MenuItem mitem){
		 
		 m_menu.addMenuItem(mitem); 
	 }
	 
	
	 
	 

}
